const express = require('express');

const cors = require("cors");

const bodyParser = require("body-parser");

const studentRouter = require('./router/student');


//引入数据库
const db = require('./db/index')

const app = express();

//静态文件及资源暴漏
app.use(express.static('public'));

//解决跨域的
app.use(cors());

//将post请求的请求体放到req.body上
app.use(bodyParser.urlencoded({extended:true}));

//应用路由
app.use(studentRouter);


app.listen(3000,err=>{
    if(!err)console.log('服务器启动成功了');
    else console.log(err);
});